package com.deYang.app.ljodfh.ui.adapter.holder;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.RelativeLayout;

import com.ruihang.generalibrary.ui.widget.CustomEXImageView;
import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.ruihang.generalibrary.utils.DateUtils;
import com.deYang.app.ljodfh.R;
import com.deYang.app.ljodfh.base.BaseActivity;
import com.deYang.app.ljodfh.beans.NewsItem;
import com.deYang.app.ljodfh.ui.activities.TopicDetailActivity;
import com.deYang.app.ljodfh.ui.utils.GlideUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by liuyu on 2017/11/20.
 */

public class TopicHomeHolder extends BaseAbsHolder<NewsItem> implements View.OnClickListener {

    @BindView(R.id.item_live_item_img)
    CustomEXImageView img;
    @BindView(R.id.lay_img)
    RelativeLayout layImg;
    @BindView(R.id.item_live_item_title)
    CustomFontTextView title;
    @BindView(R.id.item_live_label_date)
    CustomFontTextView date;
    @BindView(R.id.item_live_label_channel)
    CustomFontTextView channel;
    private NewsItem topicItem;

    public TopicHomeHolder(Context context, View itemView) {
        super(context, itemView);
        ButterKnife.bind(this, itemView);
        itemView.setOnClickListener(this);
    }

    @Override
    public void setData(NewsItem topicItem) {
        this.topicItem = topicItem;
        GlideUtil.getGlideWithLarge169DefENotFit(context, topicItem.getNewsImage()).into(img);
        title.setText(topicItem.getNewsTitle());
        date.setText(DateUtils.getDateStringForItem(DateUtils.getDataDate(topicItem)));
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(context, TopicDetailActivity.class);
        intent.putExtra(BaseActivity.EX_URL, topicItem.getNewsUrl());
        context.startActivity(intent);
    }
}
